this.BX=this.BX||{};this.BX.UI=this.BX.UI||{};(function(e,t,i){"use strict";var n=function e(){babelHelpers.classCallCheck(this,e)};babelHelpers.defineProperty(n,"NONE","none");babelHelpers.defineProperty(n,"OK","ok");babelHelpers.defineProperty(n,"CANCEL","cancel");babelHelpers.defineProperty(n,"YES","yes");babelHelpers.defineProperty(n,"NO","no");babelHelpers.defineProperty(n,"OK_CANCEL","ok_cancel");babelHelpers.defineProperty(n,"YES_NO","yes_no");babelHelpers.defineProperty(n,"YES_CANCEL","yes_cancel");babelHelpers.defineProperty(n,"YES_NO_CANCEL","yes_no_cancel");function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function o(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?s(Object(i),!0).forEach((function(t){babelHelpers.defineProperty(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var l=function(){function e(){var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"popupWindow",null);babelHelpers.defineProperty(this,"title",null);babelHelpers.defineProperty(this,"message",null);babelHelpers.defineProperty(this,"modal",true);babelHelpers.defineProperty(this,"popupOptions",{});babelHelpers.defineProperty(this,"minWidth",300);babelHelpers.defineProperty(this,"minHeight",150);babelHelpers.defineProperty(this,"maxWidth",400);babelHelpers.defineProperty(this,"buttons",[]);babelHelpers.defineProperty(this,"okCallback",null);babelHelpers.defineProperty(this,"cancelCallback",null);babelHelpers.defineProperty(this,"yesCallback",null);babelHelpers.defineProperty(this,"noCallback",null);i=t.Type.isPlainObject(i)?i:{};this.popupOptions=t.Type.isPlainObject(i.popupOptions)?i.popupOptions:{};this.cache=new t.Cache.MemoryCache;this.handleButtonClick=this.handleButtonClick.bind(this);this.modal=i.modal!==false;this.cacheable=i.cacheable===true;this.setTitle(i.title);this.setMessage(i.message);this.setOkCallback(i.onOk);this.setCancelCallback(i.onCancel);this.setYesCallback(i.onYes);this.setNoCallback(i.onNo);if(t.Type.isBoolean(i.mediumButtonSize)){this.mediumButtonSize=i.mediumButtonSize}else if(this.getTitle()!==null){this.mediumButtonSize=true}if(this.isMediumButtonSize()){this.minWidth=400;this.minHeight=200;this.maxWidth=500}this.minWidth=t.Type.isNumber(i.minWidth)?i.minWidth:this.minWidth;this.minHeight=t.Type.isNumber(i.minHeight)?i.minHeight:this.minHeight;this.maxWidth=t.Type.isNumber(i.maxWidth)?i.maxWidth:this.maxWidth;this.setOkCaption(i.okCaption);this.setCancelCaption(i.cancelCaption);this.setYesCaption(i.yesCaption);this.setNoCaption(i.noCaption);this.setButtons(i.buttons)}babelHelpers.createClass(e,[{key:"show",value:function e(){if(this.getPopupWindow().isDestroyed()){this.popupWindow=null}this.getPopupWindow().show()}},{key:"close",value:function e(){this.getPopupWindow().close()}},{key:"getPopupWindow",value:function e(){if(this.popupWindow===null){this.popupWindow=new i.Popup(o({bindElement:null,className:this.isMediumButtonSize()?"ui-message-box ui-message-box-medium-buttons":"ui-message-box",content:this.getMessage(),titleBar:this.getTitle(),minWidth:this.minWidth,minHeight:this.minHeight,maxWidth:this.maxWidth,overlay:this.modal?{opacity:20}:null,cacheable:this.cacheable,closeIcon:false,contentBackground:"transparent",padding:0,buttons:this.getButtons()},this.popupOptions))}return this.popupWindow}},{key:"setMessage",value:function e(i){if(t.Type.isString(i)||t.Type.isDomNode(i)){this.message=i;if(this.popupWindow!==null){this.popupWindow.setContent(i)}}}},{key:"getMessage",value:function e(){return this.message}},{key:"setTitle",value:function e(i){if(t.Type.isString(i)){this.title=i;if(this.popupWindow!==null){this.popupWindow.setTitleBar(i)}}}},{key:"getTitle",value:function e(){return this.title}},{key:"setButtons",value:function e(i){if(t.Type.isArray(i)){this.buttons=i}else if(t.Type.isString(i)){this.buttons=this.getButtonsLayout(i)}if(this.popupWindow!==null){this.popupWindow.setButtons(this.buttons)}}},{key:"getButtons",value:function e(){return this.buttons}},{key:"setOkCaption",value:function e(i){if(t.Type.isString(i)){this.getOkButton().setText(i)}}},{key:"setCancelCaption",value:function e(i){if(t.Type.isString(i)){this.getCancelButton().setText(i)}}},{key:"setYesCaption",value:function e(i){if(t.Type.isString(i)){this.getYesButton().setText(i)}}},{key:"setNoCaption",value:function e(i){if(t.Type.isString(i)){this.getNoButton().setText(i)}}},{key:"setOkCallback",value:function e(i){if(t.Type.isFunction(i)){this.okCallback=i}}},{key:"setCancelCallback",value:function e(i){if(t.Type.isFunction(i)){this.cancelCallback=i}}},{key:"setYesCallback",value:function e(i){if(t.Type.isFunction(i)){this.yesCallback=i}}},{key:"setNoCallback",value:function e(i){if(t.Type.isFunction(i)){this.noCallback=i}}},{key:"isMediumButtonSize",value:function e(){return this.mediumButtonSize}},{key:"getOkButton",value:function e(){var i=this;return this.cache.remember("okBtn",(function(){return new BX.UI.Button({id:n.OK,size:i.isMediumButtonSize()?BX.UI.Button.Size.MEDIUM:BX.UI.Button.Size.SMALL,color:BX.UI.Button.Color.PRIMARY,text:t.Loc.getMessage("UI_MESSAGE_BOX_OK_CAPTION"),events:{click:i.handleButtonClick}})}))}},{key:"getCancelButton",value:function e(){var i=this;return this.cache.remember("cancelBtn",(function(){return new BX.UI.CancelButton({id:n.CANCEL,size:i.isMediumButtonSize()?BX.UI.Button.Size.MEDIUM:BX.UI.Button.Size.SMALL,text:t.Loc.getMessage("UI_MESSAGE_BOX_CANCEL_CAPTION"),events:{click:i.handleButtonClick}})}))}},{key:"getYesButton",value:function e(){var i=this;return this.cache.remember("yesBtn",(function(){return new BX.UI.Button({id:n.YES,size:i.isMediumButtonSize()?BX.UI.Button.Size.MEDIUM:BX.UI.Button.Size.SMALL,color:BX.UI.Button.Color.PRIMARY,text:t.Loc.getMessage("UI_MESSAGE_BOX_YES_CAPTION"),events:{click:i.handleButtonClick}})}))}},{key:"getNoButton",value:function e(){var i=this;return this.cache.remember("noBtn",(function(){return new BX.UI.Button({id:n.NO,size:i.isMediumButtonSize()?BX.UI.Button.Size.MEDIUM:BX.UI.Button.Size.SMALL,color:BX.UI.Button.Color.LIGHT_BORDER,text:t.Loc.getMessage("UI_MESSAGE_BOX_NO_CAPTION"),events:{click:i.handleButtonClick}})}))}},{key:"getButtonsLayout",value:function e(t){switch(t){case n.OK:return[this.getOkButton()];case n.CANCEL:return[this.getCancelButton()];case n.YES:return[this.getYesButton()];case n.NO:return[this.getNoButton()];case n.OK_CANCEL:return[this.getOkButton(),this.getCancelButton()];case n.YES_NO:return[this.getYesButton(),this.getNoButton()];case n.YES_CANCEL:return[this.getYesButton(),this.getCancelButton()];case n.YES_NO_CANCEL:return[this.getYesButton(),this.getNoButton(),this.getCancelButton()];default:return[]}}},{key:"handleButtonClick",value:function e(t,i){var n=this;if(t.isDisabled()){return}t.setDisabled();var s=this["".concat(t.getId(),"Callback")];if(!s){t.setDisabled(false);this.close();return}var o=s(this,t,i);if(o===true){t.setDisabled(false);this.close()}else if(o===false){t.setDisabled(false)}else if(o&&(Object.prototype.toString.call(o)==="[object Promise]"||o.toString()==="[object BX.Promise]")){t.setWaiting();o.then((function(e){t.setWaiting(false);n.close()}),(function(e){t.setWaiting(false)}))}}}],[{key:"alert",value:function e(i){var n=null;var s=null;var o=null;for(var l=arguments.length,a=new Array(l>1?l-1:0),u=1;u<l;u++){a[u-1]=arguments[u]}if(a.length){if(t.Type.isString(a[0])){n=a[0];s=a[1];o=a[2]}else{s=a[0];o=a[1]}}this.show({message:i,title:n,okCaption:o,onOk:s,buttons:BX.UI.Dialogs.MessageBoxButtons.OK})}},{key:"confirm",value:function e(i){var n=null;var s=null;var o=null;var l=null;for(var a=arguments.length,u=new Array(a>1?a-1:0),r=1;r<a;r++){u[r-1]=arguments[r]}if(u.length){if(t.Type.isString(u[0])){n=u[0];s=u[1];o=u[2];l=u[3]}else{s=u[0];o=u[1];l=u[2]}}this.show({message:i,title:n,okCaption:o,onOk:s,onCancel:l,buttons:BX.UI.Dialogs.MessageBoxButtons.OK_CANCEL})}},{key:"show",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=this.create(t);i.show()}},{key:"create",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return new this(t)}}]);return e}();e.MessageBox=l;e.MessageBoxButtons=n})(this.BX.UI.Dialogs=this.BX.UI.Dialogs||{},BX,BX.Main);
//# sourceMappingURL=dialogs.bundle.map.js